import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn, CreateDateColumn } from 'typeorm';
import { Student } from '../../student/entities/student.entity';
import { CourseOffering } from '../../course_offering/entities/course_offering.entity';

@Entity('select_course')
export class SelectCourse {
    @PrimaryGeneratedColumn()
    select_id: number;

    @ManyToOne(() => Student)
    @JoinColumn({ name: 'sno' })
    student: Student;

    @ManyToOne(() => CourseOffering)
    @JoinColumn({ name: 'offering_id' })
    courseOffering: CourseOffering;

    @Column({ name: 'score', type: 'decimal', precision: 5, scale: 2, nullable: true })
    score: number;  // 成绩

    @Column({ name: 'status', type: 'enum', enum: ['selected', 'dropped'], default: 'selected' })
    status: string;  // 选课状态：已选/已退选

    @CreateDateColumn({ name: 'select_time' })
    selectTime: Date;  // 选课时间

    @Column({ name: 'drop_time', type: 'timestamp', nullable: true })
    dropTime: Date;  // 退课时间
}